#!/usr/bin/python

from SocketServer import (TCPServer as Tcp,StreamRequestHandler as Srh)
from time import ctime
import socket

host = ''
port = 12345
addr = (host,port)

class MyHandler(Srh):
	def handle(self):
		print '...connect from: %s', self.client_address
		for line in self.rfile:
			ret = '[%s] %s'%(ctime(),line)
			print ret
			self.wfile.write(ret)

server = Tcp(addr,MyHandler)
server.socket.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)
print 'waiting for ...'
server.serve_forever()
